package cn.xingyun.pickaxe_loli_new.mixin;

import cn.xingyun.pickaxe_loli_new.init.NewLoliPickaxeModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GameRenderer.class)
public class GameRendererMixin {
    @Shadow @Final
    Minecraft minecraft;

    @Inject(method = "bobHurt",at = @At("HEAD"),cancellable = true)
    private void bobHurt(CallbackInfo ci) {
        LivingEntity livingentity = (LivingEntity)minecraft.getCameraEntity();
        if(livingentity instanceof Player player && player.getInventory().contains(NewLoliPickaxeModItems.LOLIPICKAXE.get().getDefaultInstance())) {
            ci.cancel();
        }
    }
}
